import React from 'react';

import { Header } from '@/widgets/Header';
import { PasswordPage as Component } from '@/pagesComponents/Auth';
import { innerUrls } from '@/shared/constants/urls';
import { generateMetaData } from '@/shared/lib/meta';
import { storageTokens } from '@/shared/lib/storage';
import Head from 'next/head';
import { useRouter } from 'next/router';
import { useWindowSize } from 'usehooks-ts';

import Auth from '..';

export default function PasswordPage() {
  const { width } = useWindowSize();
  const router = useRouter();
  React.useEffect(() => {
    if (storageTokens.getAccessToken() || storageTokens.getRefreshToken()) {
      router.push(innerUrls.main);
    }
  }, []);
  return (
    <>
      <Head>{generateMetaData({ title: 'Вход' })}</Head>
      {width > 1024 ? <Auth /> : <Header />}
      <Component />
    </>
  );
}
